<template>
	<view class="wrapper">
		<view class="infoList" v-for="(item,index) in searchinfolist" :key="index" @tap="searchProinfo(item.proID)">
			<view class="line">
				<view class="infoProbox">
					<view class="infoProname">{{item.proname}}</view>
					<view class="infoprotime">{{item.protime}}</view>	
				</view>
				<image src="../../static/tabimg/details.png" class="imgdetail"></image>
			</view>
		</view>
	</view>
</template>

<script>
	import {post} from "../../lib/Util.js"
	export default{
		data(){
			return{
				searchinfolist:[]
			}
		},
		methods:{
			searchProinfo(val){
				uni.navigateTo({
					url:'../pojectinfo/pojectinfo?id='+val
				})
			},
			/**
			 * 关键字搜索
			 */
			async getInputtips(val) {
				let data = {
					id : uni.getStorageSync('userID'),
					value: val
				}
				let res = await post('pro/findProByName',data)
				let result = res.data
				if(result.length === 0){
					uni.showToast({
						icon:'none',
						title: '暂无该项目'
					})
				}else{
					for(let i=0;i<result.length;i++){
						this.searchinfolist.push({
							proname: result[i].proName,
							protime: result[i].proLinTestTime,
							proID : result[i].id
						})
					}
				}
			}
		},
		/**
		 * 当 searchInput 输入时触发
		 */
		onNavigationBarSearchInputChanged(e) {
			this.searchinfolist = []
			let text = e.text;
			if (!text) {
				this.isHistory = true;
				this.historyList = [];
				this.historyList = uni.getStorageSync('search:history');
				return;
			} else {
				this.isHistory = false;
				this.getInputtips(text);
			}
		},
	}
</script>

<style>
	.wrapper{
		padding: 0 20rpx;
		box-sizing: border-box;
		height: 100vh;
		background: #f4f5f6;
	}
	.infoList{
		width: 100%;
		height: 100rpx;
		padding: 15rpx 55rpx;
		box-sizing: border-box;
		border-bottom: 1px #EEEEEE solid;
	}
	.line{
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.infoProbox{
		width: 80%;
	}
	.infoProname{
		font-size: 24rpx;
		color: #000000;
		font-weight: 400;
		font-family: PingFangSC-Semibold, sans-serif;
		margin-bottom: 10rpx;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
	.infoprotime{
		font-size: 18rpx;
		font-weight: 300;
		color: #505153;
		font-family: PingFangSC-Ultralight, sans-serif;
		overflow: hidden;
		white-space: nowrap;
	}
	.imgdetail{
		width: 15rpx;
		height: 30rpx;
	}
</style>
